<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<style type="text/css">
	
	#container{
		margin: 10px;
	}

</style>
</head>
<body>
<div id="container">
	<form action="delWorkServlet" method="post">
		<table class="table table-bordered table-striped table-hover">
			<thead>
				<tr>
					<td></td>
					<td>快递编号</td>
					<td>快递种类</td>
					<td>取货地址</td>
					<td>送达地址</td>
					<td>操作</td>
				</tr>
			</thead>
			<tbody> 
			<c:forEach var="good" items="${goods}">
				<tr>
					<td>
						<input type="checkbox" id="ids" name="ids" class="noDetail" value="${good.goods_id }" />
					</td>
					<td>${good.goods_id}</td>
					<td>${good.gkind_id}</td>
					<td>${good.goods_getadd }</td>
					<td>${good.goods_sendadd}</td>
					
					<td>
						<a 
							onclick="ready()">送达</a>
						</td>
				</tr>
				<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">你确定要提交运件${good.goods_id }吗</h4>
            </div>
           
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="dofinish(${good.goods_id })">提交</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>
<!-- /.modal -->
			</c:forEach>
	
			</tbody>
			<tfoot>
				<tr>
					<td colspan="7" class="text-center"style="text-align:center" >
						<button type="submit" class="btn btn-lg btn-danger" onclick="allin()">批量送达</button>
					</td>
				</tr>
			</tfoot>
		</table>
	</form>
</div>

<script type="text/javascript" src="bootstrap/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript">
　function ready(){

	$('#myModal').modal('show');
　}
	function dofinish(id)
	{
		
		jQuery.post("GoodsFinishServlet",{"goodsId":id },function(rst){
		if(rst=='true')
				{alert("提交成功");
		window.location.href="delWorkServlet";
	}
			else alert("提交失败");
		});
	}
	//我们在后台完成货物送达
	
	function allin(){
var nofids="";
$(".noDetail").each(function(){
if($(this).is(":checked")){
nofids += $(this).val()+",";
}
});
if(nofids==""){
alert("没事点一点");
return;
}
else{
$(".noDetail").each(function(){
	if($(this).is(":checked")){
	jQuery.post("GoodsFinishServlet",{"goodsId":$(this).val() },function(){});	
}
});
alert("已全部提交");
}
}

	     
	
</script>
</html>